package br.com.novavendas.dao;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;

import br.com.novavendas.model.Orcamento;

public class DaoOrcamento extends Dao<Orcamento> implements IDao<Orcamento> {

	public DaoOrcamento() {
		super(Orcamento.class);
	}

	@Override
	public void salva(Orcamento objeto) throws Exception {
		Session session = super.getSession();
		Transaction tx = session.beginTransaction();
		try{	
			if (objeto.getId() == null)
				session.save(objeto);
			else
				session.update(objeto);
			tx.commit();
		}catch(Exception ex){
			ex.printStackTrace();
			throw ex;
		}finally{
			session.close();
		}	
		
	}

	@Override
	public void deleta(Orcamento objeto) throws Exception {
		Session session = super.getSession();
		Transaction tx = session.beginTransaction();
		try{
			session.delete(objeto); 
			tx.commit();
		}catch(Exception ex){
			ex.printStackTrace();
			throw ex;
		}finally{
			session.close();
		}
		
	}

	@Override
	public Orcamento getById(Orcamento objeto) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Orcamento> listagem() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Orcamento> listagemNome(String nome) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

}
